// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   AuthTag.java

package com.hfstu.pms.web.taglibs;

import com.hfstu.framework.common.tree.CommonTreeNode;
import com.hfstu.pms.dataaccess.service.tree.ResourceTree;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AuthTag
{

	private static Logger log = LoggerFactory.getLogger(com/hfstu/pms/web/taglibs/AuthTag);

	public AuthTag()
	{
	}

	public static boolean hasAuth(HttpServletRequest request, String resourceIds, String actionCode)
	{
		boolean hasPms = true;
		HttpSession session;
		String superAdmin;
		session = request.getSession();
		superAdmin = String.valueOf(session.getAttribute("v_superAdmin"));
		if ("1".equals(superAdmin))
			return hasPms;
		String resourceId;
		String systemCode;
		Map rtMap;
		String resources[] = resourceIds.split("_");
		resourceId = resourceIds.substring(0, resourceIds.lastIndexOf("_"));
		if (log.isInfoEnabled())
			log.info((new StringBuilder("resourceId=")).append(resourceId).append(",actionCode = ").append(actionCode).toString());
		systemCode = resources[resources.length - 1];
		Map sessionMap = (Map)session.getAttribute("session_user_pmstree");
		rtMap = (Map)sessionMap.get((String)session.getAttribute("v_userId"));
		if (rtMap == null) goto _L2; else goto _L1
_L1:
		ResourceTree rt = (ResourceTree)rtMap.get(systemCode);
		if (rt == null) goto _L2; else goto _L3
_L3:
		Iterator iterator;
		CommonTreeNode node = rt.getTreeNode(resourceId);
		List childrens = node.getChildren();
		iterator = childrens.iterator();
		  goto _L4
_L5:
		String oldActionCode;
		CommonTreeNode commonTreeNode = (CommonTreeNode)iterator.next();
		if (!commonTreeNode.isChecked() || !"controlFunc".equals(commonTreeNode.getType()))
			continue; /* Loop/switch isn't completed */
		Map map = (Map)commonTreeNode.getBindData();
		oldActionCode = (String)map.get("actionCode");
		if (actionCode.equalsIgnoreCase(oldActionCode))
			return hasPms;
_L4:
		if (iterator.hasNext()) goto _L5; else goto _L2
_L2:
		if (log.isInfoEnabled())
			log.info((new StringBuilder("resourceIds=")).append(resourceIds).append(",actionCode = ").append(actionCode).toString());
		hasPms = false;
		break MISSING_BLOCK_LABEL_344;
		Exception e;
		e;
		log.error(null, e);
		hasPms = false;
		return hasPms;
	}

}
